package org.jradweb.test.unitils;

import java.util.Properties;

import org.unitils.core.ConfigurationLoader;
import org.unitils.core.Unitils;

public class JUnitlsExtend extends Unitils {
	private static Unitils unitils=null;
	/**
     * Returns the singleton instance
     *
     * @return the singleton instance, not null
     */
    public static synchronized Unitils getInstance() {
        if (unitils == null) {
            initSingletonInstance();
        }
        return unitils;
    }

    
    /**
     * Initializes the singleton instance to the default value, loading the configuration using the {@link
     * ConfigurationLoader}
     */
    public static void initSingletonInstance() {
        unitils = new Unitils();
        unitils.init();
    }

    /**
     * Initializes unitils with the configuration files.
     */
    public void init() {
        init((String) null);
    }
	

    /**
     * Initializes unitils with the given custom configuration file
     *
     * @param customConfigurationFileName The name of the custom configuration file
     */
    public void init(String customConfigurationFileName) {
        ConfigurationLoader configurationLoader = new ConfigurationLoader();
        Properties properties = configurationLoader.loadConfiguration(customConfigurationFileName);
        init(properties);
    }
}
